package com.twu.biblioteca;

import java.util.HashMap;
import java.util.List;

/**
 * Created by sahelig on 16/06/14.
 */
public class Menu
{
    private HashMap<Integer, MenuAction> menu=new HashMap<Integer, MenuAction>();
    UserInterfaceForApplication ui=new UserInterfaceForApplication();

    Menu(UserInterfaceForApplication ui,List<MenuAction> menuActionList)
    {
        this.ui=ui;
        int length=menuActionList.size();
        for(int i=0;i<length;i++)
        {
            menu.put(i+1,menuActionList.get(i));

        }

    }

 public void displayMenu() {
        ui.display("\n\n");
        for (int i:menu.keySet())
        {
            ui.display("Enter " + i + " " + menu.get(i).toString());
        }
    }

    public MenuAction getMenuActionToBePerformed(int optionChosen) {


        if(menu.containsKey(optionChosen))
        {
            return menu.get(optionChosen);
        }


        ui.display("Select a valid option!");
        return null;
    }
}
